//
//  XLVisitorTableViewController.swift
//  SinaWeibo
//
//  Created by 李凯 on 16/9/1.
//  Copyright © 2016年 kevin. All rights reserved.
//

import UIKit

class XLVisitorTableViewController: UITableViewController {
    
    var userLogin = XLUserAccountViewModel.sharedModel.userLogon
    
    //重写loadView方法
    override func loadView() {
        if userLogin {
            super.loadView()
        }else{
            setupView()
        }
    }
    
    func setupView() {
        let v = self.visitorView
        self.view = v
        
        //设置界面左右上角的注册登录按钮
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(imgName: nil, title: "注册", target: self, action: #selector(registerBtn))
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(imgName: nil, title: "登录", target: nil, action: #selector(loginBtn))
        
        //定义一个闭包
        visitorView.block = { () -> () in
            let vc = UINavigationController(rootViewController: XLOAuthViewController())
            self.navigationController!.present(vc, animated: true, completion: nil)
        }
    }
    
    //懒加载VisitorView
    lazy var visitorView: XLVisitorView = XLVisitorView()


    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    func registerBtn() {
        print("点击注册")
    }
    
    func loginBtn() {
        
    }
    
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

  
}
